package net.muchine.web.front.controller;

import java.util.List;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import net.muchine.core.domain.user.Group;
import net.muchine.core.domain.user.Preference;
import net.muchine.core.domain.user.User;
import net.muchine.core.domain.user.UserSearch;
import net.muchine.core.service.user.GroupService;
import net.muchine.core.service.user.PreferenceService;
import net.muchine.core.service.user.UserService;
import net.muchine.core.support.util.Converter;
import net.muchine.core.support.util.Debugger;
import net.muchine.web.common.Messages;
import net.muchine.web.common.Pages;
import net.muchine.web.front.forms.Link;
import net.muchine.web.front.forms.Password;
import net.muchine.web.front.forms.Account;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

@Controller
@RequestMapping("/admin")
public abstract class AdminController extends BaseController {
	@ModelAttribute("adminMenus")
	public List<Link> getAdminMenus(HttpServletRequest request) {
		List<Link> adminMenus = codes.getAdminMenus();
		String path = request.getServletPath();
		
		for (Link link : adminMenus) {
			if (path.startsWith(link.getUrl())) {
				link.setStyle(link.getStyle() + " selected");
			}
		}
		
		return adminMenus;
	}
}
